import {
  Column,
  Entity,
  PrimaryGeneratedColumn,
  Tree,
  TreeChildren,
  TreeParent,
} from 'typeorm';
import { Product } from './product.entity';

@Entity('tb_category', {
  comment: '分类表',
})
@Tree('closure-table')
export class Category {
  @PrimaryGeneratedColumn('increment', { comment: '自增主键', unsigned: true })
  id: number;

  @TreeParent()
  parent: Category;

  @TreeChildren()
  children: Category[];

  @Column({ comment: '分类名称' })
  name: string;

  @Column({ comment: '分类图标' })
  icon: string;

  @Column({ comment: '分类描述' })
  description: string;

  products: Product[];
}
